package com.ideaaedi.zoo.diy.artifact.auth.satoken.properties;

import com.ideaaedi.zoo.commonbase.component.auth.AuthUrlWhitelist;
import com.ideaaedi.zoo.diy.artifact.auth.satoken.properties.nested.ZooAuthBasic;
import com.ideaaedi.zoo.diy.artifact.auth.satoken.properties.nested.ZooAuthToken;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.validation.annotation.Validated;

import java.util.Collection;
import java.util.Collections;

/**
 * sa-token相关配置
 *
 * @author <font size = "20" color = "#3CAA3C"><a href="https://gitee.com/JustryDeng">JustryDeng</a></font> <img
 * src="https://gitee.com/JustryDeng/shared-files/raw/master/JustryDeng/avatar.jpg" />
 * @since 1.0.0
 */
@Data
@Validated
@ConfigurationProperties(prefix = "sa-token.zoo-auth")
public class ZooAuthProperties implements AuthUrlWhitelist {
    
    @Valid
    @NestedConfigurationProperty
    private ZooAuthBasic basic;
    
    @Valid
    @NestedConfigurationProperty
    @NotNull(message = "zoo-token filter cannot be blank.")
    private ZooAuthToken token;
    
    @Override
    public Collection<String> whitelist() {
        if (this.basic == null) {
            return Collections.emptyList();
        }
        return this.basic.whitelist();
    }
    
    
}
